package com.lam.common.base.page;

/**
 * 分页和排序数据
 * 
 * @author lam
 */
public class PageVo {
	
	/** 分页页码，从1开始 */
	protected int pageNum;

	/** 每页条数 */
	protected int pageSize;

	/** 排序列 */
	protected String orderBy;

	/** 排序的方向 "desc" 或者 "asc". */
	protected String orderDirec;

	public static int getPageNum(int pageNum) {
		return pageNum > 0 ? pageNum : 1;
	}
	
	public static int getPageSize(int pageSize) {
		return (pageSize < 1 || pageSize > 1000) ? 10 : pageSize;
	}
	
	public int getPageNum() {
		return getPageNum(pageNum);
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return getPageSize(pageSize);
	}
	
	public int getOffset() {
		return (getPageNum() -1) * getPageSize(pageSize);
	}
	
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public String getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}

	public String getOrderDirec() {
		return orderDirec;
	}

	public void setOrderDirec(String orderDirec) {
		this.orderDirec = orderDirec;
	}

}
